package com.yong.sbd.biz.mybatis.service.impl;

import com.yong.sbd.biz.mybatis.entity.SysRole;
import com.yong.sbd.biz.mybatis.mapper.SysRoleMapper;
import com.yong.sbd.biz.mybatis.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * 角色服务实现类
 *
 * @author Kang Yong
 * @date 2025/10/24
 * @since 1.0.0
 */
@Service
public class SysRoleServiceImpl implements SysRoleService {

    @Autowired
    private SysRoleMapper roleMapper;

    @Override
    public SysRole getRoleById(Long id) {
        return roleMapper.selectById(id);
    }

    @Override
    public SysRole getRoleByRoleCode(String roleCode) {
        return roleMapper.selectByRoleCode(roleCode);
    }

    @Override
    public List<SysRole> getAllRoles() {
        return roleMapper.selectAll();
    }

    @Override
    public boolean saveRole(SysRole role) {
        return roleMapper.insert(role) > 0;
    }

    @Override
    public boolean updateRole(SysRole role) {
        return roleMapper.update(role) > 0;
    }

    @Override
    public boolean deleteRole(Long id) {
        return roleMapper.deleteById(id) > 0;
    }
}